package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyTag;
import cn.wolfcode.luowowo.article.mapper.StrategyTagMapper;
import cn.wolfcode.luowowo.article.service.IStrategyTagService;
import cn.wolfcode.luowowo.common.query.QueryObject;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Administrator on 2019/7/8.
 */
@Service
public class StrategyTagServiceImpl implements IStrategyTagService{
    @Autowired
    private StrategyTagMapper strategyTagMapper;
    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyTag> list = strategyTagMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(StrategyTag strategyTag) {
        if (strategyTag.getId()==null){
            strategyTagMapper.insert(strategyTag);
        }else {
            strategyTagMapper.updateByPrimaryKey(strategyTag);
        }
    }

    @Override
    public void delete(Long id) {
        strategyTagMapper.deleteByPrimaryKey(id);
    }

    @Override
    public StrategyTag get(Long rid) {
        return strategyTagMapper.selectByPrimaryKey(rid);
    }

    @Override
    public String getByDetailId(Long detailId) {
        return strategyTagMapper.selectByDetailId(detailId);
    }

    @Override
    public List<StrategyTag> list() {
        return strategyTagMapper.selectAll();
    }

}
